package com.ytjj.qmyx.admin.utils;

import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtils {

    /**
     * 验证是否为正确的邮箱号
     *
     * @param email 需要验证的邮箱地址
     * @return
     */
    public static boolean isValidEmail(String email) {
        String reg = "\\w+@(\\w+\\.){1,3}\\w+";
        Pattern pattern = Pattern.compile(reg);
        boolean flag = false;
        if (email != null) {
            Matcher matcher = pattern.matcher(email);
            flag = matcher.matches();
        }
        return flag;
    }

    /**
     * 获取map中第一个key值
     *
     * @param map 数据源
     * @return
     */
    public static Integer getKeyOrNull(Map<Integer, String> map) {
        Integer obj = null;
        for (Map.Entry<Integer, String> entry : map.entrySet()) {
            obj = entry.getKey();
            if (obj != null) {
                break;
            }
        }
        return  obj;
    }

}
